home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / pdcurs21.zip / PORTABLE.ZIP / PRINTW.C < prev    next >
Text File  |  1992-11-21  |  3KB  |  78 lines

  1. #include <stdarg.h>
  2. #include <string.h>
  3. #define        CURSES_LIBRARY  1
  4. #include <curses.h>
  5. #undef printw
  6.  
  7. #ifndef        NDEBUG
  8. char *rcsid_printw = "$Header: c:/curses/portable/RCS/printw.c%v 2.0 1992/11/15 03:29:33 MH Rel $";
  9. #endif
  10.  
  11.  
  12.  
  13.  
  14.  
  15. /*man-start*********************************************************************
  16.  
  17.   printw()     - formatted write to a window
  18.  
  19.   X/Open Description:
  20.        The printw routine adds a string to the default window
  21.        starting at the current cursor position.  This routine causes
  22.        the string that would normally be output by printf to be
  23.        output by addstr.
  24.  
  25.        The routine wprintw adds a string to the specified window
  26.        starting at the current cursor position.  This routine causes
  27.        the string that would normally be output by printf to be
  28.        output by waddstr.
  29.  
  30.        The routine mvprintw adds a string to the default window
  31.        starting at the specified cursor position.  This routine
  32.        causes the string that would normally be output by printf to
  33.        be output by addstr.
  34.  
  35.        The routine mvwprintw adds a string to the specified window
  36.        starting at the specified cursor position.  This routine
  37.        causes the string that would normally be output by printf to
  38.        be output by waddstr.
  39.  
  40.        All these routines are analogous to printf.  It is advisable
  41.        to use the field width options of printf to avoid leaving
  42.        unwanted characters on the screen from earlier calls.
  43.  
  44.   PDCurses Description:
  45.        The old Bjorn Larssen code for the 68K platform has been removed
  46.        from this module.
  47.  
  48.   X/Open Return Value:
  49.        The printw() function returns OK on success and ERR on error.
  50.  
  51.   X/Open Errors:
  52.        No errors are defined for this function.
  53.  
  54.   Portability:
  55.        PDCurses        int printw( char *fmt, ... );
  56.        X/Open Dec '88  int printw( char *fmt, ... );
  57.        BSD Curses      int printw( char *fmt, ... );
  58.        SYS V Curses    int printw( char *fmt, ... );
  59.  
  60. **man-end**********************************************************************/
  61.  
  62. int    printw(char *fmt,...)
  63. {
  64.        int     retval = ERR;
  65.        va_list args;
  66.  
  67.        if (stdscr == (WINDOW *)NULL)
  68.                return (retval);
  69.  
  70.        va_start(args, fmt);
  71.        vsprintf(c_printscanbuf, fmt, args);
  72.        va_end(args);
  73.        if (waddstr(stdscr, c_printscanbuf) == ERR)
  74.                return (retval);
  75.        retval = (strlen(c_printscanbuf));
  76.        return (retval);
  77. }
  78.